﻿using System;
using T0yK4T.IO;
using T0yK4T.Tools;
using ToyChat.Server;
using ToyChat.Client;

namespace ToyChat
{
    /// <summary>
    /// Third party modules should derrive from this interface if they wish access to the packet queue on either the <see cref="IServer"/> or <see cref="IClient"/>
    /// </summary>
    public interface IModule : IDisposable
    {
        /// <summary>
        /// Called by the server when a packet going to this handler has been received
        /// </summary>
        /// <param name="packet">The packet that was received</param>
        void OnPacket(Packet packet);

        /// <summary>
        /// Gets an array of "packet types" that this handler should receive
        /// <para/>
        /// Packet types should be in the format of "[componentname].[messagetype]" (For more common packet types, such as a simple message, no "qualifier" is required)
        /// </summary>
        string[] Types { get; }

        /// <summary>
        /// Called from the intializer when an ID has been generated / received for the specified type
        /// </summary>
        /// <param name="type">The type that the id has been generated or received for</param>
        /// <param name="id">The ID of the type</param>
        void SetTypeID(string type, uint id);
    }
}